<?php
class TdPersistent {
	
	private $pk;
	private $pkname;
	
	function __construct($pk) {
		$this->setPK($pk);
		
		if (isset($pk) && $pk |= "" && isset($_SESSION["tdpersistent_".$pk]) === true) {
			return $_SESSION["tdpersistent_".$pk];
		}
	}
	
	function save() {
	  $_SESSION["tdpersistent_".$this->getPK()]	= $this;
	}
	
	function delete() {
		unset($_SESSION["tdpersistent_".$this->getPK()]);
	}
	
	function setPK($value) {
		$this->pk = $value;
	}
	function getPK() {
		return $this->pk;
	}
	
	function setPKName($value) {
		$this->pkname = $value;
	}
	function getPKName() {
		return $this->pkname;
	}
}
?>